package cn.quang.search.admin.mapper;

import cn.quang.search.admin.entity.po.EntityLogicTableFieldDic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author:  Entity Generator
 * @since:  2024-02-28 10:26:15
 */
public interface EntityLogicTableFieldDicMapper extends BaseMapper<EntityLogicTableFieldDic> {
    @Select(
            " SELECT * FROM entity_logic_table_field_dic WHERE logic_table_id = #{logicTableId}"
    )
    List<EntityLogicTableFieldDic> selectByLogicTableId(@Param("logicTableId") long logicTableId);

    @Select(
            " SELECT * FROM entity_logic_table_field_dic WHERE field_dic_id = #{fieldDicId} "
    )
    List<EntityLogicTableFieldDic> selectByFieldDicId(@Param("fieldDicId") long fieldDicId);

    @Select(
            " SELECT logic_table_field.* " +
            " FROM ( " +
            "     SELECT id FROM entity_field_dic WHERE dic = #{fieldDicKey} " +
            " ) entity_field_dic " +
            " LEFT JOIN ( " +
            "     SELECT * FROM entity_logic_table_field_dic WHERE logic_table_id = #{logicTableId} " +
            " ) logic_table_field " +
            " ON entity_field_dic.id = logic_table_field.field_dic_id "
    )
    EntityLogicTableFieldDic selectByFieldDicKey(@Param("fieldDicKey") String fieldDicKey, @Param("logicTableId") long logicTableId);
}
